﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.IO.IsolatedStorage;

namespace YellowMap
{
    /// <summary>
    /// Use to save setting value, example: language, theme, volume,...
    /// </summary>
    public class Setting
    {
        static IsolatedStorageSettings setting = IsolatedStorageSettings.ApplicationSettings;

        /// <summary>
        /// Set default value for key setting, you should put it in Application_Launching method in App.xaml.cs
        /// </summary>
        /// <param name="key">key setting</param>
        /// <param name="defValue">default value</param>
        public static void SetDefaultValue(string key, object defValue) 
        {
            if (!setting.Contains(key)) 
            {
                setting.Add(key, defValue);
                //MessageBox.Show("Set default " + key + " = " + defValue);
            }
        }

        /// <summary>
        /// Change setting value
        /// </summary>
        /// <param name="key">key</param>
        /// <param name="value">new value</param>
        public static void Set(string key, object value)
        {
            setting[key] = value;
        }

        /// <summary>
        /// Get setting value
        /// </summary>
        /// <param name="key"></param>
        /// <returns>value of key</returns>
        public static object Get(string key)
        {
            return setting[key];
        }
       

    }
}
